import { request } from "./request.js";

$(function () {
    //点击登录按钮
    $('#loginBtn').on('click',function (e) {
        let userId=$('#userId').val();
        let password=$('#password').val();
        loginCheck(userId,password);
    })
    //检查用户名和密码是不是正确
    async function loginCheck(userId,password) {
        const res=await request({url:'/account/checkLogin',data:{userId:userId,password:password},type:'GET'});
        if (res==='fail'){
            alert("用户名或密码错误");
            $('#password').val("");
            $('#password').focus();
        }else {
            $('#loginForm').submit();
        }
    }
})